package JavaSE;
import java.util.Scanner;
// 在同一个类中,分别定义求两个整数的方法和三个小数之和的方法。并执行代码，求出结果
public class time_2025_07_04求两数之和和三数之和的求和方法重载 {
    public static double add(double num1,double num2){
        return num1+num2;
    }
    public static double add(double num1,double num2,double num3){
        return add(num1,num2)+num3;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("您要计算两个数之和还是三个数之和:（请输入2或3）");
        int input = scanner.nextInt();
        double result = 0.0;
        if(input==2){
            double num1 = scanner.nextDouble();
            double num2 = scanner.nextDouble();
            result = add(num1,num2);
        }if(input==3){
            double num1 = scanner.nextDouble();
            double num2 = scanner.nextDouble();
            double num3 = scanner.nextDouble();
            result = add(num1,num2,num3);
        }
        System.out.print("计算结果为:"+result);
    }
}
